package com.wuye.zlgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wuye.charge.domain.vo.WyBalconyunithomeVo;
import com.wuye.charge.mapper.WyBalconyunithomeVoMapper;
import com.wuye.charge.service.WyBalconyunithomeVoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.zlgl.domain.WyParkingRent;
import com.wuye.zlgl.service.IWyParkingRentService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 车位租赁Controller
 * 
 * @author 杨
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/zlgl/pakingRent")
public class WyParkingRentController extends BaseController
{
    @Autowired
    private IWyParkingRentService wyParkingRentService;
    @Autowired
    private WyBalconyunithomeVoMapper wyBalconyunithomeVoMapper;
    /**
     * 查询所有的关联房间
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:list')")
    @GetMapping("/selectRoom")
    public AjaxResult selectRoom(){
        return success(wyBalconyunithomeVoMapper.selectWyBalconyunithomeVoAll());
    }
    /**
     * 根据车位位置查询租赁信息
     *
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:list')")
    @GetMapping("/selectByParkId")
    public AjaxResult selectWyParkingRentByParkId(Long parkId){
        return success(wyParkingRentService.selectWyParkingRentByParkId(parkId));
    }
    /**
     * 根据房间id查询租赁信息
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:list')")
    @GetMapping("/selectByBalconyunithomeId")
    public AjaxResult selectWyParkingRentByBalconyunithomeId(Long balconyunithomeId){
        return success(wyParkingRentService.selectWyParkingRentByBalconyunithomeId(balconyunithomeId));
    }

    /**
     * 查询车位租赁列表
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyParkingRent wyParkingRent)
    {
        startPage();
        List<WyParkingRent> list = wyParkingRentService.selectWyParkingRentList(wyParkingRent);
        return getDataTable(list);
    }

    /**
     * 导出车位租赁列表
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:export')")
    @Log(title = "车位租赁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyParkingRent wyParkingRent)
    {
        List<WyParkingRent> list = wyParkingRentService.selectWyParkingRentList(wyParkingRent);
        ExcelUtil<WyParkingRent> util = new ExcelUtil<WyParkingRent>(WyParkingRent.class);
        util.exportExcel(response, list, "车位租赁数据");
    }

    /**
     * 获取车位租赁详细信息
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyParkingRentService.selectWyParkingRentById(id));
    }

    /**
     * 新增车位租赁
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:add')")
    @Log(title = "车位租赁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyParkingRent wyParkingRent)
    {
        return toAjax(wyParkingRentService.insertWyParkingRent(wyParkingRent));
    }

    /**
     * 修改车位租赁
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:edit')")
    @Log(title = "车位租赁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyParkingRent wyParkingRent)
    {
        return toAjax(wyParkingRentService.updateWyParkingRent(wyParkingRent));
    }

    /**
     * 删除车位租赁
     */
    @PreAuthorize("@ss.hasPermi('zlgl:pakingRent:remove')")
    @Log(title = "车位租赁", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyParkingRentService.deleteWyParkingRentByIds(ids));
    }
}
